package com.area.cth.mapper;

import com.area.cth.pojo.CommentGoods;
import com.area.cth.pojo.CommentPost;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CommentMapper extends BaseMapper<CommentPost> {
    @Insert("insert into comment_post(comment_user,post_id,content,create_time) " +
            "values (#{commentUser},#{postId},#{content},#{createTime})")
    void addCommentToPost(CommentPost c);

    @Insert("insert into comment_goods(comment_user,goods_id,content,create_time) " +
            "values (#{commentUser},#{goodsId},#{content},#{createTime})")
    void addCommentToGoods(CommentGoods c);

    List<CommentPost> getCommentPostList(Integer pId);

    List<CommentGoods> getCommentGoodsList(Integer gId);

    @Select("select count(1) from comment_post where post_id=#{pId}")
    Integer postCommentCount(Integer pId);

    List<CommentPost> commentPostListForMine(Integer id);

    List<CommentGoods> commentGoodsListForMine(Integer id);

    @Delete("delete from comment_post where id=#{id}")
    void deletePost(Integer id);

    @Delete("delete from comment_goods where id=#{id}")
    void deleteGoods(Integer id);
}
